package com.wy.powerbuilder.controller.Costs;

import com.wy.powerbuilder.entity.Costs.Cost;
import com.wy.powerbuilder.entity.lwg.houses;
import com.wy.powerbuilder.service.Costs.CostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class CostController {

    @Autowired
    private CostService costService;

    @RequestMapping("/selAllHouses")
    public String selHouses(houses houses,Model model){
        List<houses> housesList = costService.selHouses(houses);
        model.addAttribute("housesList",housesList);
        return "product-brand";
    }

    @RequestMapping("/selCost")
    public String selCost(Integer c_id,Model model){
        Cost costs= costService.selCost(c_id);
        model.addAttribute("costs",costs);
        return "product-add";
    }
    @RequestMapping("/addCost")
    public String addCost(Cost cost){
        costService.addCost(cost);
        return "forward:selAllHouses";
    }

    @RequestMapping("/selHCost")
    public String selHCost(Integer h_id,Model model){
        List<Cost> costlist = costService.selHCost(h_id);
        model.addAttribute("costlist",costlist);
        return "product-cost";

    }
}

